<?php

// +----------------------------------------------------------------------
// | 私信
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 微尘 <yicmf@qq.com>
// +----------------------------------------------------------------------

	namespace app\event\im;

	use app\common\event\Base;
	use app\model\file\Image as ImageModel;
	use app\model\im\ChatGrouping;
	use app\model\ucenter\User;
	use app\model\ucenter\User as UserModel;
	use app\model\im\Chat as ChatModel;
	use app\model\im\ChatContent as ChatContentModel;
	use think\Exception;
	use think\facade\Db;
	use think\facade\Log;

	class Customer extends Base
	{
		/**
		 * 发送者
		 * @var UserModel
		 */
		protected $user;
		/**
		 * 参数
		 * @var array
		 */
		protected $param;

		protected $from;

		/**
		 * 初始化客服
		 * @param array $param
		 * @param UserModel $user
		 */
		public function hello(array $param, UserModel $user, $device = null, $from = 0)
		{
			try {

				Db::startTrans();
				$data['data']['type'] = 'text';
				$data['data']['content'] = '早上好！';
				$data['data']['create_time'] = '刚刚';

                $data['data']['is_online'] = 1;
                $data['code'] = 0;

                $data['data']['service'] = $user;
                $data['data']['hello'] = $re['data'];
                $data['data']['hello']['user'] = $user;
//				$data['data'] = $this->_sendChatContent($myChat, $param,$user, $from);
				Db::commit();
				$data['code'] = 0;
				$data['message'] = '发送成功';
			} catch (\Exception $e) {
				// 回滚事务
				Db::rollback();
				$data['code'] = 2;
				$data['message'] = 'file:' . $e->getFile() . ',message:' . $e->getMessage() . 'li' . $e->getLine();
//				$data['message'] = $e->getMessage();
			}
			return $data;
		}

	}
